<?php
define('APPTYPEID', 100);
define('CURSCRIPT', 'misc');
require './source/class/class_core.php';
$discuz = & discuz_core::instance();

$discuz->init();

if (!submitcheck('formSubmit')){

	// Set up editor
	$editorid = 'e'; // dat ID cho bo soan thao.
	$_G['setting']['editoroptions'] = str_pad(decbin($_G['setting']['editoroptions']), 3, 0, STR_PAD_LEFT);

	$editormode = $_G['setting']['editoroptions']{0}; // gia su $_G['setting']['editoroptions'] = 'abcd' => $_G['setting']['editoroptions']{0} = 'a'
	$allowswitcheditor = $_G['setting']['editoroptions']{1}; // gia su $_G['setting']['editoroptions'] = 'abcd' => $_G['setting']['editoroptions']{1} = 'b'
	/*
	 * y o day la chung ta tach doat chuoi cai dat cua $_G['setting']['editoroptions'], voi moi vi tri tuong ung se dua ra mot gia tri cai dat
	 * **/
	$editor = array(
			'editormode'=>$editormode,
			'allowswitcheditor'=>$allowswitcheditor,
			'allowhtml'=>1,  //$_G['shop']['allowhtml'] Tuy tung noi cho phep cai dat, co the viet them trong admin de cau hinh
			'allowsmilies'=>1,  //$_G['shop']['allowsmilies'] Tuy tung noi cho phep cai dat, co the viet them trong admin de cau hinh
			'allowbbcode'=>1,  //$_G['shop']['allowbbcode'] Tuy tung noi cho phep cai dat, co the viet them trong admin de cau hinh
			'allowimgcode'=>1,  //$_G['shop']['allowimgcode'] Tuy tung noi cho phep cai dat, co the viet them trong admin de cau hinh
			'allowresize'=>1,
			'allowchecklength'=>1,
			'allowtopicreset'=>1,
			'textarea'=>'detail',  // Dat ten cho hop textarea
			'simplemode'=>!isset($_G['cookie']['editormode_' . $editorid]) ? !$_G['setting']['editoroptions']{9} : $_G['cookie']['editormode_' . $editorid],
			'value'=>'' // gia tri dua vao hop textarea de edit neu trong truong hop edit
	);

	$_G['forum']['allowmediacode'] = true; //set de hop soan thao cho phep dang media
	$_G['group']['allowmediacode'] = true; // set de cap quyen cho nhom nay dc phep dung code media
	/*
	 * Khi $_G['group']['allowmediacode'] va $_G['group']['allowmediacode'] de o trang thai true thi se mo code media
	 * **/

	if ($_G['group']['attachextensions']){
		$imgexts = explode(',', str_replace(' ', '', $_G['group']['attachextensions']));
		$imgexts = array_intersect(array(
				'jpg',
				'jpeg',
				'png',
				'bmp'
		), $imgexts);
		$imgexts = implode(', ', $imgexts);
	}else{
		$imgexts = 'jpg, jpeg, png, bmp';
	}

	$_G['group']['allowpostattach'] = FALSE; //  set de cho phep hay khong viec su dung attachment


	$notAllowInsertIMGFromAlbum = true;

	$isfirstpost = true; // o dien dan, thi day la code de cho biet rang co phai bai viet dau tien hay khong, neu la bai viet dau tien se cho phep sung
// mot so code nhu la code hide v� code free.


}else{

	require_once libfile('function/discuzcode');
	$submit = true;
	$noidung = discuzcode($_POST['detail'], 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, $_G['setting']['lazyload']);
}

include template('test/test');
?>